#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;
int main(void){
    int t;
    int c=0;
    char s1[100],s2[100];
    int res[100];
    scanf("%d",&t);
    while(t--){
        memset(res,0,sizeof(res));
        scanf("%s%s",s1,s2);
        int len1=strlen(s1);
        int len2=strlen(s2);
        int cnt=0;
        int val=0;
        int k=0;
        while(len1>0 && len2>0){
            len1--;
            len2--;
            val=cnt+(s1[len1]-'0')+(s2[len2]-'0');
            cnt=val/2;
            val%=2;
            res[k++]=val;
        }
        while(len1>0){
            len1--;
            val=(s1[len1]-'0'+cnt);
            cnt=val/2;
            val%=2;
            res[k++]=val;
        }
        while(len2>0){
            len2--;
            val=(s2[len2]-'0'+cnt);
            cnt=val/2;
            val%=2;
            res[k++]=val;
        }
        if(cnt!=0){
            res[k++]=cnt;
        }
        printf("%d ",++c);
        int one_flag=0;
        for(int i=k-1;i>=0;i--){
            if(res[i]==0 && one_flag==0){
                if(i==0){
                    printf("%d",res[i]);
                }
                else{
                    continue;
                }
            }
            else if(res[i]==1){
                one_flag=1;
                printf("%d",res[i]);
            }
            else if(one_flag==1){
                printf("%d",res[i]);
            }
        }
        printf("\n");
    }
    return 0;
}
